Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-plane

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-plane

DOM and window coordinate helpers

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
55K
increased by1.44%
Maintainers
1
Weekly downloads
 
Created
Source

Example

import {
    createPointCB,
    getClientRect,
    pointInside
} from 'dom-plane';

const point = {};
const pointCB = createPointCB(point);

window.addEventListener('mousemove', pointCB);
window.addEventListener('mousedown', (e)=>{
    console.log('point is inside '+e.target, '=', pointInside(point, e.target))
    console.log('current rect ', getClientRect(e.target))
})

Exported functions.

  • createPointCB(point)
  • getClientRect(element)
  • pointInside(point, element)

createPointCB(point) -> pointCB

point should be an object. Preferably an empty object.

createPointCB returns a function that should be set as a listener on mouse, or touch events.

Each time the event fires it on pointCB it will update point.

point

point will gain these properties:

  • target
  • element
  • type
  • pageX
  • pageY
  • x
  • y

getClientRect(element|window) -> clientRect

Get the boundingClientRect of the element, or window.

pointInside(point, element) -> Boolean

Check to see if the point is inside the element.

Keywords

FAQs

Package last updated on 15 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc